import pandas as pd
import math,time

file_path = 'data/腾讯用户登录游戏数据.txt'
user_infos = pd.read_table(file_path,header=None,sep=',',encoding='utf-8')
print(user_infos)
#print(user_infos.loc[[1,3,4],[2,5,7,8]])
size = user_infos.keys().size

keylist = list(range(size))
namelist = ['编号','游戏名称','姓名','性别','出生日期','身高','地区','上线时间','下线时间']
headDict = dict(zip(keylist,namelist))
user_infos.reset_index()
user_infos.rename(columns=headDict,inplace=True)
new_user_infos = user_infos.loc[1:4,['编号','游戏名称','姓名','出生日期','地区']]
print(new_user_infos)
#cover = new_user_infos.loc[:,'游戏名称']=='王者荣耀'
#print(new_user_infos[cover])
#留下四川的
#area_loc = user_infos.loc[:,'地区']
#area_cover = [area.find('四川')>=0 for area in area_loc]
#print(user_infos.loc[area_cover])
#身高和171差距3厘米以内的留下
high_loc = user_infos.loc[:,'身高']

#hgih_cover = [math.fabs(high - 171) < 3 for high in high_loc]
#print('身高遮罩')
#print(user_infos.loc[hgih_cover])
#年龄和29岁相差2岁以内
birthday_loc = user_infos.loc[:,'出生日期']
currYear = time.localtime(time.time()).tm_year
age_cover = [math.fabs((currYear-time.strptime(birthday[0:10:],'%Y-%m-%d').tm_year) - 29) < 3 for birthday in birthday_loc]
print('身高遮罩')
print(user_infos.loc[age_cover])

highs = [172,166,155]
#for index,high in  enumerate(highs):
    #highs[index] = high + 20    #highs[index] #第index个元素

highs = [high+20 for index,high in  enumerate(highs)] #一个列表是可以循环的，循环出的每个元素可以做固定处理形成新的列表
                                                      #处理分两种 1.修改值  2.保留值
print(highs)

highs = [high>190 for index,high in  enumerate(highs)] #一个列表是可以循环的，循环出的每个元素可以做固定处理形成新的列表
                                                      #处理分两种 1.修改值  2.保留值
print(highs)



